// pages/my_account/index.js
var app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        userInfo: {
            nickname:'小投',
            headImgUrl: '/images/icon-avatar.png',
            mobile: '131****2950',
            email: '5***4@qq.com',
        }
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this;
        wx.showLoading({
            title: "加载中",
            mask: true
        })

        var sessionId = wx.getStorageSync('sessionId')
        if (sessionId) {
            this.setData({
                ["userInfo.nickName"]: app.globalData.userInfo.nickName,
                ["userInfo.avatarUrl"]: app.globalData.userInfo.avatarUrl,
            });
        }

        app.WxRequest.getRequest('/wxmp/getUserInfo')
        .then(res => {
            if (res.data.code != '-1') {
                that.setData({
                    userInfo: res.data.wxUserVo,
                });
            }
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },
    logout() {
        // 用户退出
        wx.removeStorageSync("sessionId");
        wx.showToast({
            title: '删除session',
        })
    },
    handleinfo(e){
        console.log(e);
    },
    handlephone(e){
        console.log(e);
    }
})